﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Abhiruchi_Phase1
{
    class SearchEmployeeDAL
    {
        public static SqlConnection myCon = new SqlConnection(App.ConnectionString);        
        public static DataTable LoadAllEmpDataFromDB(int type)
        {
           SqlCommand myCom= LoadSp();      
            myCom.Parameters.AddWithValue("@int_ProcessType", type);
            DataTable myDt = new DataTable();
            SqlDataAdapter myda = new SqlDataAdapter(myCom);
           
            myda.Fill(myDt);
            return myDt;
        }
        public static DataTable LoadAllEmpDataFromDB(int type,string no)
        {
            SqlCommand myCom = LoadSp();     
            myCom.Parameters.AddWithValue("@EmployeeNo", no);
            myCom.Parameters.AddWithValue("@int_ProcessType", type);
            DataTable myDt = new DataTable();

            SqlDataAdapter myda = new SqlDataAdapter(myCom);
            myda.Fill(myDt);
            return myDt;
        }
        public static DataTable LoadAllEmpDataFromDB(string name,int type )
        {
            SqlCommand myCom = LoadSp();
            myCom.Parameters.AddWithValue("@EmployeeName", name);            
            myCom.Parameters.AddWithValue("@int_ProcessType", type);
            DataTable myDt = new DataTable();

            SqlDataAdapter myda = new SqlDataAdapter(myCom);
            myda.Fill(myDt);
            return myDt;
        }
        public static DataTable LoadAllEmpDataFromDB(int type,string name,string no)
        {
            SqlCommand myCom = LoadSp();
            myCom.Parameters.AddWithValue("@EmployeeName", name);
            myCom.Parameters.AddWithValue("@int_ProcessType", type);
            myCom.Parameters.AddWithValue("@EmployeeNo", no);
            DataTable myDt = new DataTable();         

            SqlDataAdapter myda = new SqlDataAdapter(myCom);
            myda.Fill(myDt);
            return myDt;
        }

        private static SqlCommand LoadSp()
        {
            SqlCommand myCom = new SqlCommand();
            myCom.Connection = myCon;
            myCom.CommandText = "sp_HRM_Get_Set_PE_CE_SearchEmployee";
            myCom.CommandType = CommandType.StoredProcedure;
            return myCom;
        }
    }
}
